/***************************************************************************\
 * The Mattise Kernel														*
 * Copyright 2007 Matthew Iselin											*
 * Licensed under the GPL													*
 *																			*
 * portio.cc																*
 *																			*
 * Handles port I/O, nothing more, nothing less.							*
 *																			*
\***************************************************************************/

#include <system.h>

/// Output to a port, byte size
void outportb( short port, char dat )
{
	__asm__ __volatile__ ( "outb %1,%0" : : "dN" (port), "a" (dat) );
}

/// Output to a port, short size
void outportw( short port, short dat )
{
	__asm__ __volatile__ ( "outw %1,%0" : : "dN" (port), "a" (dat) );
}

/// Output to a port, int size
void outportl( short port, int dat )
{
	__asm__ __volatile__ ( "outl %1,%0" : : "dN" (port), "a" (dat) );
}

/// Input from a port, byte size
char inportb( short port )
{
	char dat;
	__asm__ __volatile__ ( "inb %1, %0" : "=a" (dat) : "dM" (port) );
	return dat;
}

/// Input from a port, short size
short inportw( short port )
{
	short dat;
	__asm__ __volatile__ ( "inw %1, %0" : "=a" (dat) : "dM" (port) );
	return dat;
}

/// Input from a port, short size
int inportl( short port )
{
	int dat;
	__asm__ __volatile__ ( "inl %1, %0" : "=a" (dat) : "dM" (port) );
	return dat;
}
